<div id="login_popup" title="Autenticarme">
	<table class="form-table">		
		<tr>
			<td><label for="login_email">E-mail:</label></td>
			<td>
				<input id="login_email" maxlength="45" name="login_email" class="validate[required, custom[email]]"/>		
			</td>
		</tr>
		
		<tr>
			<td><label for="login_email">Password:</label></td>
			<td>
				<input id="login_password" maxlength="45" type="password" name="login_password" class="validate[required, minSize[6]]"/>		
			</td>
		</tr>
	</table>	
</div>

<script type="text/javascript">

	// Init
	$(function() {
		var login_popup = $("#login_popup");
		
		login_popup.dialog({
			autoOpen: false,
			height: 210,
			position: {
				my: "right top",
				at: "right-4 top",
				of: "#menu-container"
			},
			buttons: {
	            Aceptar : function() {
					var email = $("#login_email");
					var password = $("#login_password");
		
					if(email.val() == "")
					{				
						email.css("border", "1px solid #FF0000");
						$('label[for="' + email.attr('id') + '"]').css("color", "#FF0000");				
					} 
		
					if(password.val() == "")
					{
						password.css("border", "1px solid #FF0000");
						$('label[for="' + password.attr('id') + '"]').css("color", "#FF0000")
					} 
					
					if(email.val() != "" && password.val() != "")
					{
						$.post("<?php echo site_url(array("auth", "autenticar"));?>", {login_email: email.val(), login_password: password.val()})
						
						.done(function(){
							window.location = "<?php echo site_url(array('inicio'));?>";			
						})
		
						.fail(function(error) {
							mostrarMensajeError(error.responseText);
						});
					}
	            }	            
	        }
		});
	});
	
	function login_popup_open(caller)
	{
		$("#login_popup").dialog("open");
	}
	
</script>
